home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / fish / 001-100 / 001-025 / 016 / source.files / iff / remalloc.h < prev    next >
C/C++ Source or Header  |  1995-03-17  |  3KB  |  86 lines

  1. /** RemAlloc.h **********************************************************/
  2. /*  ChipAlloc(), ExtAlloc(), RemAlloc(), RemFree().            */
  3. /*  ALLOCators which REMember the size allocated, for simpler freeing.    */
  4. /*                                                                      */
  5. /* Date      Who Changes                                                */
  6. /* --------- --- -------------------------------------------------------*/
  7. /* 16-Jan-86 sss Created from DPaint/DAlloc.c                           */
  8. /* 22-Jan-86 jhm Include Compiler.h                      */
  9. /* 25-Jan-86 sss Added ChipNoClearAlloc,ExtNoClearAlloc                 */
  10. /*                                                                      */ 
  11. /* By Jerry Morrison and Steve Shaw, Electronic Arts.                   */ 
  12. /* This software is in the public domain.                               */ 
  13. /*                                                                      */ 
  14. /* This version for the Commodore-Amiga computer.                       */
  15. /*                                                                      */ 
  16. /************************************************************************/
  17. #ifndef REM_ALLOC_H
  18. #define REM_ALLOC_H
  19.  
  20. #ifndef COMPILER_H
  21. #include "iff/compiler.h"
  22. #endif
  23.  
  24.  
  25. /* How these allocators work:
  26.  * The allocator procedures get the memory from the system allocator,
  27.  * actually allocating 4 extra bytes. We store the length of the node in
  28.  * the first 4 bytes then return a ptr to the rest of the storage. The
  29.  * deallocator can then find the node size and free it. */
  30.  
  31.  
  32. #ifdef FDwAT
  33.  
  34. /* RemAlloc allocates a node with "size" bytes of user data.
  35.  * Example:
  36.  *   struct BitMap *bm;
  37.  *   bm = (struct BitMap *)RemAlloc( sizeof(struct BitMap), ...flags... );
  38.  */
  39. extern UBYTE *RemAlloc(LONG, LONG);
  40.             /* size, flags */
  41.  
  42. /* ALLOCator that remembers size, allocates in CHIP-accessable memory.
  43.  * Use for all data to be displayed on screen, all sound data, all data to be
  44.  * blitted, disk buffers, or access by any other DMA channel.
  45.  * Does clear memory being allocated.*/    
  46. extern UBYTE *ChipAlloc(LONG);
  47.              /* size */
  48.  
  49. /* ChipAlloc, without clearing memory.  Purpose: speed when allocate
  50.  * large area that will be overwritten anyway.*/
  51. extern UBYTE *ChipNoClearAlloc(LONG);
  52.     
  53. /* ALLOCator that remembers size, allocates in extended memory.
  54.  * Does clear memory being allocated.
  55.  * NOTICE: does NOT declare "MEMF_FAST".  This allows machines
  56.  * lacking extended memory to allocate within chip memory,
  57.  * assuming there is enough memory left.*/    
  58. extern UBYTE *ExtAlloc(LONG);
  59.             /* size */
  60.  
  61. /* ExtAlloc, without clearing memory.  Purpose: speed when allocate
  62.  * large area that will be overwritten anyway.*/
  63. extern UBYTE *ExtNoClearAlloc(LONG);
  64.  
  65.  
  66. /* FREEs either chip or extended memory, if allocated with an allocator
  67.  * which REMembers size allocated.
  68.  * Safe: won't attempt to de-allocate a NULL pointer.
  69.  * Returns NULL so caller can do
  70.  *   p = RemFree(p);
  71.  */
  72. extern UBYTE *RemFree(UBYTE *);
  73.           /*  p  */
  74.  
  75. #else /* not FDwAT */
  76.  
  77. extern UBYTE *RemAlloc();
  78. extern UBYTE *ChipAlloc();
  79. extern UBYTE *ExtAlloc();
  80. extern UBYTE *RemFree();
  81.  
  82. #endif /* FDwAT */
  83.  
  84. #endif REM_ALLOC_H
  85.  
  86.